/*
** proc_regs.c for pud in mrcellophane/libpud
** 
** Made by solomon hykes
** Login   <torgau@gmail.com>
** 
** Started on  Mon May 16 17:26:49 2005 solomon hykes
** Last update Sun Jun  5 01:20:21 2005 solomon hykes
*/

#include "pud_sys.h"

t_ret	sys_pud_getregs(sys_pud_process *p)
{
  sys_pud_process	*proc = (sys_pud_process *)p;

  while (ptrace(PT_GETREGS, proc->pid, (caddr_t)(&proc->regs), 0) == -1)
    if (errno != EAGAIN)
      return (ret_err);
  /* MACHINE-DEPENDANT */ proc->pc = proc->regs.r_eip;
  /* MACHINE-DEPENDANT */ proc->stackp = proc->regs.r_esp;
  return (ret_ok);
}

t_ret	sys_pud_setregs(sys_pud_process *p)
{
  sys_pud_process	*proc = p;

  while (ptrace(PT_SETREGS, proc->pid, (caddr_t)(&proc->regs), 0) == -1)
    if (errno != EAGAIN)
      return (ret_err);
  /* MACHINE-DEPENDANT */ proc->pc = proc->regs.r_eip;
  /* MACHINE-DEPENDANT */ proc->stackp = proc->regs.r_esp;
  return (ret_ok);
}
